package com.lkd.controller;

import com.lkd.dto.RegionDto;
import com.lkd.entity.Region;
import com.lkd.service.IRegionService;
import com.lkd.vo.PageBean;
import com.lkd.vo.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: RegionController
 * Package: com.lkd.controller
 * Description:
 *
 * @Author zt
 * @Create 2025/10/11 21:55
 * @Version 1.0
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/vm-service/region")
public class RegionController {

    private final IRegionService regionService;

    /**
     * 区域搜索
     * @param regionDto
     * @return
     */
    @GetMapping("/search")
    public Result search(RegionDto regionDto){
        PageBean<Region> pageBean  =regionService.search(regionDto);
        return Result.success(pageBean);
    }

    /**
     * 新增区域
     */
    @PostMapping
    public Result saveRegion(@RequestBody Region region){
        boolean save = regionService.save(region);
        return Result.success(save);
    }

    /**
     * 修改区域
     */
    @PutMapping
    public Result updateRegion(@RequestBody Region region){
        boolean updated = regionService.updateById(region);
        return Result.success(updated);
    }

}
